package cn.javase.concurrent._并发编程._03_Java线程._线程常用API;

import static java.lang.Thread.sleep;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class _interrupt {

    public static void main(String[] args) throws InterruptedException {
        // 打断sleep的线程，会清空打断状态
        Thread t1 = new Thread(() -> {
            try {
                sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }, "t1");
        t1.start();
        sleep(1000);
        t1.interrupt();
        log.debug(" 打断状态: {}", t1.isInterrupted());
    }

    /*
        TODO 打断标记这里还需要完善一下
        打断sleep的线程，会清空打断状态；打断正常运行的线程，不会情况打断状态
     */
    private static void testSleepInterrupted() throws InterruptedException {

    }

}
